package com.liukai.todo_android.entity;

import com.liukai.todo_android.common.utils.Constants;
import com.liukai.todo_android.common.utils.DateUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：liukai
 * @date ：Created in 2021/8/25 5:06 下午
 * @description：详情实体类
 * @modified By：
 * @version: $
 */
public class DetailVo {

    private String title;

    private String content;

    public String getTitle() {
        return title;
    }

    public DetailVo setTitle(String title) {
        this.title = title;
        return this;
    }

    public String getContent() {
        return content;
    }

    public DetailVo setContent(String content) {
        this.content = content;
        return this;
    }

    public DetailVo() {
    }

    public DetailVo(String title, String content) {
        this.title = title;
        this.content = content;
    }

    @Override
    public String toString() {
        return "DetailVo{" +
                "title='" + title + '\'' +
                ", content='" + content + '\'' +
                '}';
    }

    public static List<DetailVo> buildDetailList(ItemVo itemVo) {

        List<DetailVo> detailVoList = new ArrayList<>();
        if (itemVo.getTitle() != null && !"".equals(itemVo.getTitle())) {
            detailVoList.add(new DetailVo("标题:", itemVo.getTitle()));
        }
        if (itemVo.getDescription() != null && !"".equals(itemVo.getDescription())) {
            detailVoList.add(new DetailVo("备注:", itemVo.getDescription()));
        }
        if (itemVo.getSummary() != null && !"".equals(itemVo.getSummary())) {
            detailVoList.add(new DetailVo("专注心得:", itemVo.getSummary()));
        }
        if (itemVo.getFinished() != null) {
            detailVoList.add(new DetailVo("是否完成:",
                    itemVo.getFinished() == Constants.SCHEDULE_NOT_FINISHED ? "未完成" : "已完成"));
        }
        if (itemVo.getGmtCreate() != null) {
            detailVoList.add(new DetailVo("创建时间:", DateUtil.getYearMonthDay(itemVo.getGmtCreate())));
        }
        if (itemVo.getTimingType() != null) {
            detailVoList.add(new DetailVo("计时类型:", getTimingType(itemVo.getTimingType())));
        }
        return detailVoList;
    }

    private static String getTimingType(int type) {
        if (type == Constants.TIMING_TYPE_NO) {
            return "无";
        }
        if (type == Constants.TIMING_TYPE_UP) {
            return "正计时";
        }
        if (type == Constants.TIMING_TYPE_DOWN) {
            return "倒计时";
        }
        return "无";
    }

}
